/** 
 * Project Name:eleme-website 
 * File Name:ShopDao.java 
 * Package Name:com.eleme.dao.impl 
 * Date:2017年12月26日下午4:30:46 
 * Copyright (c) 2017, fakedesigner@163.com All Rights Reserved. 
 * 
*/  
  
package com.eleme.dao.impl;

import java.sql.PreparedStatement;
import java.sql.ResultSet;

import com.eleme.dao.IShopDetailDao;
import com.eleme.entity.Shop;
import com.eleme.entity.V_Shop_Detail;

/** 
 * ClassName:ShopDao <br/> 
 * Function: TODO ADD FUNCTION. <br/> 
 * Reason:   TODO ADD REASON. <br/> 
 * Date:     2017年12月26日 下午4:30:46 <br/> 
 * @author   Pan 
 * @version   
 * @since    JDK 1.8 
 * @see       
 */
public class ShopDao extends BaseDao<Shop> implements IShopDetailDao{

	
	//TODO: 修改返回类型为对应的实体类
	public Shop createEntity() {
		return new Shop();
	}
	
	
	
	public V_Shop_Detail getShopDetail(int shopid) {
		PreparedStatement ps = null;
		ResultSet rs = null;
		V_Shop_Detail res = null;
		String sql = "Select id, name, logo, rate, servicerate, dishrate, address,"
				+ " higher, opentime, closetime, dtldesc, lowestprice, deliverfee, avgdlvtime, deliverman, "
				+ "insurance, invoice, monthlysold, sanitationlv, fullname, legalperson, lisence, "
				+ "lisencevalidity, lisencephoto1, lisencephoto2 "
				+ "From V_Shop_Detail Where id = ?";
		LOGGER.debug(sql);
		try {
			try {
				ps = getConnection().prepareStatement(sql);
				ps.setInt(1, shopid);
				rs = ps.executeQuery();
				if(rs != null && rs.next()) {
					res = new V_Shop_Detail();
					res.setId(rs.getInt("id"));
					res.setName(rs.getString("name"));
					res.setLogo(rs.getString("logo"));
					res.setRate(rs.getFloat("rate"));
					res.setServicerate(rs.getFloat("servicerate"));
					res.setDishrate(rs.getFloat("dishrate"));
					res.setAddress(rs.getString("address"));
					res.setHigher(rs.getFloat("higher"));
					res.setOpentime(rs.getTime("opentime"));
					res.setClosetime(rs.getTime("closetime"));
					res.setDtldesc(rs.getString("dtldesc"));
					res.setLowestprice(rs.getFloat("lowestprice"));
					res.setDeliverfee(rs.getFloat("deliverfee"));
					res.setAvgdlvtime(rs.getString("avgdlvtime"));
					res.setDeliverman(rs.getString("deliverman"));
					res.setInsurance(rs.getInt("insurance"));
					res.setInvoice(rs.getInt("invoice"));
					res.setMonthlysold(rs.getInt("monthlysold"));
					res.setSanitationlv(rs.getString("sanitationlv"));
					res.setFullname(rs.getString("fullname"));
					res.setLegalperson(rs.getString("legalperson"));
					res.setLisence(rs.getString("lisence"));
					res.setLisencevalidity(rs.getDate("lisencevalidity"));
					res.setLisencephoto1(rs.getString("lisencephoto1"));
					res.setLisencephoto2(rs.getString("lisencephoto2"));
					
				}
			} finally {
				rs.close();
				ps.close();
			}
			
			
		} catch (Exception e) {
			LOGGER.error("getShopDetail出错：" + e.getMessage());
			e.printStackTrace();
		}
		
		return res;
	}



	public static void main(String[] args) {
		// TODO Auto-generated method stub
		ShopDao self = new ShopDao();
		V_Shop_Detail o = self.getShopDetail(1);
		System.out.println(o.getOpentime());
	}

}
